package com.ccq.service;

import com.alibaba.fastjson.JSON;
import com.ccq.mapper.AllfloorMapper;
import com.ccq.model.Allfloor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LastAllfloorService {
    @Autowired
    AllfloorMapper allfloorMapper;

    public String userlist(Integer page){
        page=(page-1)*5;
        List<Allfloor> ls=allfloorMapper.selectPage(page);
        String aListJson = JSON.toJSONString(ls);
        System.out.println(aListJson);
        return aListJson;
    }

    public String add(Allfloor allfloor){
        int add=allfloorMapper.insertSelective(allfloor);
        List<Allfloor> ls=allfloorMapper.selectPage(0);
        String aListJson = JSON.toJSONString(ls);
        return aListJson;
    }

    public String eidts(int id){
        Allfloor se=allfloorMapper.selectByPrimaryKey(id);
        String aListJson = JSON.toJSONString(se);
        return aListJson;
    }

    public String edit(Allfloor allfloor){
        int  se=allfloorMapper.updateByPrimaryKey(allfloor);
        List<Allfloor> ls=allfloorMapper.selectPage(0);
        String aListJson = JSON.toJSONString(ls);
        return aListJson;
    }

    public String del(int id){
        int del=allfloorMapper.deleteByPrimaryKey(id);
        List<Allfloor> ls=allfloorMapper.selectPage(0);
        String aListJson = JSON.toJSONString(ls);
        System.out.println("删除成功！");
        return aListJson;
    }
}
